package timing.ukulele.third.controller.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.common.PhoneRegisterDTO;
import timing.ukulele.data.third.data.common.SysThirdPartyUserDTO;
import timing.ukulele.data.third.view.common.SysThirdPartyUserVO;
import timing.ukulele.third.service.common.SysThirdPartyUserService;

/**
 * 第三方用户
 * @author zh
 */
@RestController
@Slf4j
@RequestMapping("/sysThirdPartyUser")
public class SysThirdPartyUserController {

    private final SysThirdPartyUserService sysThirdPartyUserService;

    public SysThirdPartyUserController(SysThirdPartyUserService sysThirdPartyUserService) {
        this.sysThirdPartyUserService = sysThirdPartyUserService;
    }

    /**
     * /thirdPartyUser/page
     * @param dto
     * @return
     */
    @Operation(summary = "分页列表")
    @PostMapping("/page")
    public ResponseData<IPage<SysThirdPartyUserVO>> pageList(@RequestBody SysThirdPartyUserDTO dto) {
        return ResponseData.success(sysThirdPartyUserService.pageList(dto));
    }

    /**
     * 获取platSource和platId第三方用户信息
     * @param platSource
     * @param platId
     * @return
     */
    public ResponseData<SysThirdPartyUserVO> getByPlatSourceAndId(Integer platSource, String appId, String platId) {
        return ResponseData.success(sysThirdPartyUserService.getByPlatSourceAndId(platSource, appId, platId));
    }

    /**
     * 根据输入手机号注册用户
     * @param phoneRegisterDTO
     * @return
     */
    @PostMapping("/phoneRegister")
    public ResponseData<String> phoneRegister(@RequestBody PhoneRegisterDTO phoneRegisterDTO) {
        return sysThirdPartyUserService.phoneRegister(phoneRegisterDTO);
    }

}
